// UVa10820 Send a Table
// 刘汝佳
#include <cmath>
#include <cstdio>
const int NN = 50000;
int Phi[NN + 1], PhiS[NN + 1];

void phi_table(int n) { // 预处理欧拉函数表
  Phi[1] = 0;
  for (int i = 2; i <= n; i++) {
    if (Phi[i]) continue;
    for (int j = i; j <= n; j += i) {
      int &pj = Phi[j];
      if (pj == 0) pj = j;
      pj = pj / i * (i - 1);
    }
  }
}

int main() {
  phi_table(NN);
  PhiS[0] = 0;
  for (int i = 1; i <= NN; i++) PhiS[i] = PhiS[i - 1] + Phi[i];
  for (int n; scanf("%d", &n) == 1 && n;) printf("%d\n", 2 * PhiS[n] + 1);
  return 0;
}
/*
算法分析请参考: 《入门经典-第2版》例题 10-7
*/
// 24514970 10820 Send a Table Accepted C++11 0.000 2020-02-05 12:28:31